package com.youmu.xxessj.ac

import android.content.Intent
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import com.leon.lfilepickerlibrary.LFilePicker
import com.youmu.xxessj.R
import com.youmu.xxessj.ut.UPDATESJ
import com.youmu.xxessj.ut.Utils
import kotlinx.android.synthetic.main.activity_fbsj.*
import kotlinx.android.synthetic.main.activity_upsj.*
import kotlinx.android.synthetic.main.heard.*

class upsjActivity : AppCompatActivity() {
    private lateinit var path:String
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_upsj)
        init_heard()
    }
    fun init_heard(){
        heard_back.setOnClickListener {
            finish()
        }
        heard_ok.text= "提交"
        heard_ok.setOnClickListener {
            initsp()
        }
        heard_title.text = "修改书籍"
        upbookname.setText(intent.getStringExtra("bookname"))
        upbookcb.setText(intent.getStringExtra("bookcb"))
        upbookzz.setText(intent.getStringExtra("pbookzz"))
        upfile.setOnClickListener {
            LFilePicker()
                    .withActivity(this@upsjActivity)
                    .withRequestCode(100)
                    .withFileFilter(listOf(".png",".jpg").toTypedArray())
                    .withMutilyMode(false)
//                .withFileSize((500 * 1024).toLong())
                    .start()
        }
    }

    private fun initsp() {
        UPDATESJ
    }

    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        super.onActivityResult(requestCode, resultCode, data)
        if (resultCode == RESULT_OK) {
            if (requestCode ==100) { // 视频
                val list = data?.getStringArrayListExtra("paths")
                path = list!![0]
                up_file.text=path
            }

        }
    }
}
